<!--  -->
<template>
  <div class="">
    <p-PageForm :layout="layout" :formDataList="formDataList"></p-PageForm>
  </div>
</template>

<script>
import getDataForDB from '@/api/qsbBusinessManagement'
export default {
  // import引入的组件需要注入到对象中才能使用
  name: 'EntRegistInfo',
  components: {},
  props: {
    dataInfo: {
      type: Object,
    },
    closeEvent:{type:Function}
  },
  data() {
    // 这里存放数据
    return {
      layout:{
        rowNum: 4, columnNum: 3, rowGap: "1px", rowHeight:'100px', coliumnGap: "10px", labelCol: { span: 9 }, wrapperCol: { span: 11 },
      },
      formDataList:[
        { enName:'entName', cnName:'企业名称', type:'label',value:'测试数据'},
        { enName:'entName111', cnName:'', type:'label',value:''},
        { enName:'lisenceCreditCode', cnName:'社会信用统一代码', type:'label',value:'测试数据'},
        { enName:'lisenceRegisterTime', cnName:'注册时间', type:'label',value:'测试数据'},
        { enName:'bankName', cnName:'开户行', type:'label',value:'测试数据'},
        { enName:'legalName', cnName:'企业负责人', type:'label',value:'测试数据'},
        { enName:'legalPhone', cnName:'负责人手机', type:'label',value:'测试数据'},
        { enName:'cardNumber', cnName:'负责人身份证', type:'label',value:'测试数据'},
        { enName:'bankNo', cnName:'银行账户', type:'label',value:'测试数据'},
        { enName:'lisenceAddress', cnName:'经营场所', type:'label',value:'测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据',numRowsOccupied: 1, numColumnOccupied: 3 ,formItemAttr:{labelCol: { span: 3 }, wrapperCol: { span: 20 }},itemAttr:{}},
        { enName:'lisenceMgrNature', cnName:'经营范围', type:'label',value:'测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据',numRowsOccupied: 1, numColumnOccupied: 3 ,formItemAttr:{labelCol: { span: 3 }, wrapperCol: { span: 20 }},itemAttr:{}},
        { enName:'licenseUrl', cnName:'营业执照', type:'imgGroup',value:[
          {url:'',title:'营业执照',isShowWatermark: false}
        ],numRowsOccupied: 1, numColumnOccupied: 3 ,formItemAttr:{labelCol: { span: 3 }, wrapperCol: { span: 20 }},itemAttr:{}},
      ],
      qsbDetails:{}
    };
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {
    dataInfo: {
      handler(val) {
        this.setData4RegistInfo(val)
      },
      deep: true,
      immediate: true
    },
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  // 方法集合
  methods: {
    setFormItemData(dataList){

      const getValList = {
        'licenseUrl':(val)=>{ return [{url:val,title:'营业执照',isShowWatermark: false}]}
      }

      this.formDataList.forEach(item=>{
        if(getValList[item.enName]){
          item.value = getValList[item.enName](dataList[item.enName])
        }else{
          item.value = dataList[item.enName] || ''
        }
      })
    },
    setData4RegistInfo(dataInfo){
      const {entId} = dataInfo
      getDataForDB('企业注册信息查询',{entId}).then(res=>{
        const {success,result,message} = res
        if(success==true){
          const {baseInfo,legalInfo,openBankInfo,...args} = result
          this.qsbDetails = {...baseInfo,...legalInfo,...openBankInfo,...args}
          this.setFormItemData(this.qsbDetails )
        }else{
          this.$message.warning(message||'接口请求出错了')
        }
      })
    }
  },
  }
</script>
<style lang='less' scoped>
</style>
